﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Media;
using System.Windows;
using System.Threading;


namespace MasterDetailEx.Notify
{
    public class PopupNotify
    {
        public static Thread t = null;

        static Label msg;

        public static bool CheckIsAlive()
        {

            if (PopupNotify.t != null)
            {
                return PopupNotify.t.IsAlive;

            }
            return false;

        }/////////



        public static void start(MainWindow mw, string mensaje)
        {
            //if (!PopupNotify.CheckIsAlive())
            //{
            PopupNotify.t = new Thread(() =>
            {
                //msg = lbl;
                msg = mw.lbl_ad;
                Action a = () => updateStatus(mensaje);
                Application.Current.Dispatcher.BeginInvoke(a, System.Windows.Threading.DispatcherPriority.Background);

            });

            PopupNotify.t.IsBackground = true;
            PopupNotify.t.Start();
            //}
        }// end start

        protected static void updateStatus(string mensaje)
        {
            msg.Content = "Último estatus: " + mensaje;
            Thread.Sleep(1200);


        }


    }// end class

}
